import os

directory = "/Users/lijiqiao/Downloads/20230322uyReskct/bird_detect/ann_txt-811"  # 要修改的目录
for filename in os.listdir(directory):
    if filename.endswith(".txt"):  # 只处理txt文件
        filepath = os.path.join(directory, filename)
        with open(filepath, "r") as file:
            lines = file.readlines()
        with open(filepath, "w") as file:
            for line in lines:
                if line[0].isdigit() and line[0] == "0":  # 找到第一个数字为0的行
                    line = "1" + line[1:]  # 替换第一个数字为1
                file.write(line)
